<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<isperp:changeView>

	<jsp:body> 

<table class="form-table">
	<jsp:include page="step1view.jsp"></jsp:include>
   <%--  <jsp:include page="step2view.jsp"></jsp:include> --%>
	
</table>

<form class="validate" id="changeForm" action="change/change/save"
			method="post">
	<input name="id" type="hidden" value="${model.id }"> 
<table class="form-table">
<c:if test="${not empty model.riskEvaluate }">
	<div class="header">
		<h3>变更实施</h3>
	</div>

	<tr>
				<td class="td1">验证人：</td>
				<td class="td2"><input type="hidden" id="identifier"
							value="${model.identifier }" name="identifier" /> <isperp:departmentUser
								displayValue="${model.identifierName }" roleNames="项目经理"
								valueControlId="identifier" id="identifierName"
								idFieldName="name" name="identifierName"
								displayValueCssClass="required"></isperp:departmentUser>
								</td>
			</tr>
					
	
	
		<tr style="display:none">
			<td class="td1">实施成本：</td>
			<td class="td2" colspan="3"><isperp:grid
								url="project/costAccountingEntry/listByRelationId?relationId=${model.id }"
								gridId="accountingEntryGrid" cusFormatterActions="true"
								height="auto" showPager="false" rownumbers="false"
								showSearchbar="false"
								beforeEditAction="accountingEntryGridEdit(id); return false;"
								cusEditUrl="project/costAccountingEntry/edit?projectId=${model.projectId}"
								ondbClickRowEvent="accountingEntryGridEdit(rowid);"
								cusDeleteUrl="project/costAccountingEntry/delete">

					<jsp:attribute name="toolbar">
									
					<isperp:toolbar id="iconToolbar">
						<isperp:button text="添加成本项" icon="icon-plus"
											onclick="accountingEntryGridEdit();"></isperp:button>
					</isperp:toolbar>
					</jsp:attribute>
					<jsp:body>
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="cost_subject_name" title="科目" width="90">
					</isperp:column>
					<isperp:column name="amount" title="金额（元）" width="50">
					</isperp:column>
					<isperp:column name="handler_name" title="经手人" width="60">
					</isperp:column>
					<isperp:column name="occurrence_date" title="发生日期" width="60">
						
					</isperp:column>
					<isperp:column name="memo" title="备注" width="120">
					</isperp:column>
					</jsp:body>
				</isperp:grid>
						</td>
		</tr>
</c:if>
<c:if test="${not empty  model.executer}">
       <tr>
			<td class="td1">实施日期：</td>
			<td class="td2"><input id="executeTime" name="executeTime"
							class="datetime required2" type="dateTime"
							value="${model.executeTime }">
			</td>


			<td class="td1">实施者：</td>
			<td class="td2"><input id="executer" name="executer"
							type="hidden" value="${model.executer }"> <isperp:departmentUser
								displayValue="${model.executerName }" valueControlId="executer"
								id="executerName" name="executerName"
								displayValueCssClass="required2"></isperp:departmentUser>
			</td>

		</tr>
		<tr>
			<td class="td1">实施结果：</td>
			<td class="td2" colspan="3"><textarea id="executeResult"
								name="executeResult" class="required2">${model.executeResult }</textarea>

			</td>
	</tr>
	<%-- 	<tr>
	<td class="td2" colspan="4">
		<div class="header">
			<h3>评估验证</h3>
		</div>
	</td>
</tr>
		<tr>
			<td class="td1">评估结果：</td>
			<td class="td2" colspan="3">
			  <isperp:dictSelector name="evaluationResult"
							selectedValue="${model.evaluationResult }" hasEmptyValue="false"
							dictCssClass="required" id="evaluationResult"
							typeCode="CHANGE_RESULT"></isperp:dictSelector>
			</td>
		</tr>
		<tr>
			<td class="td1">实施后效果评估：</td>
			<td class="td2" colspan="3"><textarea id="effectEvaluation"
								name="effectEvaluation" class="required2">${model.effectEvaluation }</textarea>

			</td>
		</tr> --%>
		
		<tr style="display:none">
			<td class="td1">供应商：</td>
			<td class="td2" colspan="3"><input id="providerId"
							name="providerId" type="hidden" value="${model.providerId }">
				<isperp:listSelector id="providerIdSelector"
								url="provider/provider/list"
								displayValue="${model.providerName }" name="providerName"
								valueControlId="providerId">
					<isperp:column name="id" title="id" hidden="true"></isperp:column>
					<isperp:column name="code" title="编号" width="80">
					</isperp:column>
					<isperp:column name="name" title="名称" width="150">
					</isperp:column>
					<isperp:column name="linkman" title="联系人" width="80">
					</isperp:column>
					<isperp:column name="linktel" title="联系电话" width="80">
					</isperp:column>
					<isperp:column name="serviceTel" title="客服电话" width="80">
					</isperp:column>
					<isperp:column name="supportTel" title="技术支持电话" width="80">
					</isperp:column>
				</isperp:listSelector>
			</td>
		</tr>

</c:if>
	</table>
</form>

	</jsp:body>

</isperp:changeView>


<div id="accountingEntryDialog" title="成本项"
	style="display:none;padding:5px">
	<iframe id="accountingEntryIframe" scrolling="no" src=""
		style="width:100%;height:100%;;border:none;overflow: hidden;padding:0;margin:0"></iframe>
</div>
<isperp:buttonList>
	<isperp:processButtons processKey="changeProcess" formId="changeForm"
		processId="${model.processId }" businessKey="${model.id }"></isperp:processButtons>
</isperp:buttonList>


<script type="text/javascript">
	var $accountingEntryDialog = $("#accountingEntryDialog").dialog({
		modal : true,
		autoOpen : false,
		width : 500,
		height : 450,
		open : function(event, ui) {
			$("#createCusUserId").val("");

		},
		buttons : {
			保存 : function() {
				var $me = $(this);
				isperp.getWindow("accountingEntryIframe").sumbitForm(function(id) {
					$me.dialog("close");
					accountingEntryGrid.reload();
				});

			}

		}
	});
	function accountingEntryGridEdit(rowid) {

		var url = "project/costAccountingEntry/edit?projectId=${model.projectId}&relationId=${model.id}";
		if (rowid)
			url = url + "&id=" + rowid;

		$("#accountingEntryIframe").attr("src", url);

		$accountingEntryDialog.dialog("open");
	}

	function formatSelector(rowObject, gridId) {
		return "<a class=\"nui-txt-link\" onclick=\"" + gridId + ".jqGrid.setSelection('" + rowObject.id + "');" + gridId + "Selected();\">选择</a>";
	}

	function formatCiName(rowObject) {
		return "<a href=\"javascript:isperp.openDialog({contentUrl:'configuration/ci/ciResumeView?id=" + rowObject.id + "'});\">" + rowObject.name + "</a>";
	}

	var assAssectGridSelected = function(id, name) {
		if (!id && !name) {
			var selectedRow = assAssectGrid.getRowData();
			id = selectedRow.id;
			name = selectedRow.name;
		}
		if (id && name) {
			var msg = {
				id : id,
				name : name
			};
			var rs = formatCiName(msg);
			$("#assAssetId").val(id);
			$("#ci_idMsg").html(rs);
		}
	};

	function customerCi_Onclick() {
		isperp.openDialog({
			onThisWindow : true,
			title : "选择关联资产",
			windowSize : "normal",
			contentUrl : "customer/customer/customerCiEdit?customerId=",
			buttons : [ {
				text : "确定",
				"class" : "nui-mainbtn",
				click : function() {
					var $me = $(this);
					$me.find("iframe")[0].contentWindow.getSelectRow(function(id, name) {
						assAssectGridSelected(id, name);
						$me.wijdialog("close");
					});
				}
			}, {
				text : "关闭",
				"class" : 'grey',
				click : function() {
					$(this).wijdialog("close");
				}
			} ]
		});

	}
</script>



<c:choose>
	<c:when test="${empty model.ciId }">

	</c:when>
	<c:otherwise>
		<script type="text/javascript">
			assAssectGridSelected("${model.ciId}", "${model.ciName}");
		</script>
	</c:otherwise>
</c:choose>